package com.eiss.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.eiss.domain.DTO.DeliverystationsDTO;
import com.eiss.domain.VO.DeliverystationsVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.eiss.common.annotation.Log;
import com.eiss.common.core.controller.BaseController;
import com.eiss.common.core.domain.AjaxResult;
import com.eiss.common.enums.BusinessType;
import com.eiss.domain.Entily.Deliverystations;
import com.eiss.service.IDeliverystationsService;
import com.eiss.common.utils.poi.ExcelUtil;
import com.eiss.common.core.page.TableDataInfo;

/**
 * 站点管理Controller
 * 
 * @author gzh
 * @date 2025-01-18
 */
@RestController
@Slf4j
@RequestMapping("/deliverystations/deliverystationsmanage")
public class DeliverystationsController extends BaseController
{
    @Autowired
    private IDeliverystationsService deliverystationsService;

    /**
     * 查询站点管理列表
     */
    @PreAuthorize("@ss.hasPermi('deliverystations:deliverystationsmanage:list')")
    @GetMapping("/list")
    public TableDataInfo list(Deliverystations deliverystations)
    {
        startPage();
        List<DeliverystationsDTO> list = deliverystationsService.selectDeliverystationsList(deliverystations);
        return getDataTable(list);
    }

    /**
     * 导出站点管理列表
     */
    @PreAuthorize("@ss.hasPermi('deliverystations:deliverystationsmanage:export')")
    @Log(title = "站点管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Deliverystations deliverystations)
    {
        List<DeliverystationsDTO> list = deliverystationsService.selectDeliverystationsList(deliverystations);
        ExcelUtil<DeliverystationsDTO> util = new ExcelUtil<DeliverystationsDTO>(DeliverystationsDTO.class);
        util.exportExcel(response, list, "站点管理数据");
    }

    /**
     * 获取站点管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('deliverystations:deliverystationsmanage:query')")
    @GetMapping(value = "/{StationID}")
    public AjaxResult getInfo(@PathVariable("StationID") Long StationID)
    {
        return success(deliverystationsService.selectDeliverystationsByStationID(StationID));
    }

    /**
     * 新增站点管理
     */
    @PreAuthorize("@ss.hasPermi('deliverystations:deliverystationsmanage:add')")
    @Log(title = "站点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeliverystationsVO deliverystationsVO)
    {
        log.info("前端数据:{}",deliverystationsVO);
        return toAjax(deliverystationsService.insertDeliverystations(deliverystationsVO));
    }

    /**
     * 修改站点管理
     */
    @PreAuthorize("@ss.hasPermi('deliverystations:deliverystationsmanage:edit')")
    @Log(title = "站点管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeliverystationsVO deliverystationsVO)
    {
        return toAjax(deliverystationsService.updateDeliverystations(deliverystationsVO));
    }

    /**
     * 删除站点管理
     */
    @PreAuthorize("@ss.hasPermi('deliverystations:deliverystationsmanage:remove')")
    @Log(title = "站点管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{StationIDs}")
    public AjaxResult remove(@PathVariable Long[] StationIDs)
    {
        return toAjax(deliverystationsService.deleteDeliverystationsByStationIDs(StationIDs));
    }
    @PostMapping("/Nearbystation")
    public AjaxResult Nearbystation(Double x,Double y)
    {
        return success(deliverystationsService.Nearbystation(x,y));
    }
}
